package roleService

import (
	roleDto "news_for_deepseek_interface/dto/admin/system/role"
	"news_for_deepseek_interface/model"
	adminModel "news_for_deepseek_interface/model/admin"
	"strconv"
	"strings"
)

func UpdateGroup(params roleDto.UpdateGroupRequest) error {
	db := model.GetInstance().GetDB().Model(&adminModel.AdminGroupStruct{})

	ruleStringSlice := make([]string, len(params.Rules))
	for i, num := range params.Rules {
		ruleStringSlice[i] = strconv.Itoa(num)
	}

	return db.Where("id = ?", params.Id).
		Update("rules", strings.Join(ruleStringSlice, ",")).
		Error
}
